package com.shop.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.GenericGenerator;

/**
 * Order entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "order", catalog = "myshop")
public class Order implements java.io.Serializable {

	// Fields

	private Integer eoId;
	private User user;
	private String eoUserName;
	private String eoUserAddress;
	private Date eoCreateTime;
	private Float eoCost;
	private Integer eoStatus;
	private Set<OrderDetail> orderDetails = new HashSet<OrderDetail>(0);

	// Constructors

	/** default constructor */
	public Order() {
	}

	/** minimal constructor */
	public Order(User user, String eoUserName, String eoUserAddress,
			Date eoCreateTime, Float eoCost, Integer eoStatus) {
		this.user = user;
		this.eoUserName = eoUserName;
		this.eoUserAddress = eoUserAddress;
		this.eoCreateTime = eoCreateTime;
		this.eoCost = eoCost;
		this.eoStatus = eoStatus;
	}

	/** full constructor */
	public Order(User user, String eoUserName, String eoUserAddress,
			Date eoCreateTime, Float eoCost, Integer eoStatus,
			Set<OrderDetail> orderDetails) {
		this.user = user;
		this.eoUserName = eoUserName;
		this.eoUserAddress = eoUserAddress;
		this.eoCreateTime = eoCreateTime;
		this.eoCost = eoCost;
		this.eoStatus = eoStatus;
		this.orderDetails = orderDetails;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "increment")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "eo_id", unique = true, nullable = false)
	public Integer getEoId() {
		return this.eoId;
	}

	public void setEoId(Integer eoId) {
		this.eoId = eoId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "eo_user_id", nullable = false)
	public User getUser() {
		return this.user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Column(name = "eo_user_name", nullable = false, length = 20)
	public String getEoUserName() {
		return this.eoUserName;
	}

	public void setEoUserName(String eoUserName) {
		this.eoUserName = eoUserName;
	}

	@Column(name = "eo_user_address", nullable = false, length = 200)
	public String getEoUserAddress() {
		return this.eoUserAddress;
	}

	public void setEoUserAddress(String eoUserAddress) {
		this.eoUserAddress = eoUserAddress;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "eo_create_time", nullable = false, length = 10)
	public Date getEoCreateTime() {
		return this.eoCreateTime;
	}

	public void setEoCreateTime(Date eoCreateTime) {
		this.eoCreateTime = eoCreateTime;
	}

	@Column(name = "eo_cost", nullable = false, precision = 12, scale = 0)
	public Float getEoCost() {
		return this.eoCost;
	}

	public void setEoCost(Float eoCost) {
		this.eoCost = eoCost;
	}

	@Column(name = "eo_status", nullable = false)
	public Integer getEoStatus() {
		return this.eoStatus;
	}

	public void setEoStatus(Integer eoStatus) {
		this.eoStatus = eoStatus;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "order")
	public Set<OrderDetail> getOrderDetails() {
		return this.orderDetails;
	}

	public void setOrderDetails(Set<OrderDetail> orderDetails) {
		this.orderDetails = orderDetails;
	}

}